﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using HRProject.Code.DAO;
using HRProject.Code.Common;
using System.Collections.Generic;
using HRProject.Code.DTO;

namespace HRProject.Asset
{
    public partial class ViewAssetType : System.Web.UI.Page
    {
        private Guid typeId = Guid.Empty;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string id = Request.Params["id"];
                try
                {
                    typeId = new Guid(id);
                }
                catch (Exception exp)
                {
                    Console.Out.Write(exp.StackTrace);
                    typeId = Guid.Empty;
                }
                AssetTypeDAO dao = new AssetTypeDAO();
                BLAssetType filter = new BLAssetType();
                filter.Id = typeId;
                filter.Name = string.Empty;
                filter.Parent = new BLAssetType();
                filter.Parent.Id = Guid.Empty;
                List<BLAssetType> assetTypes = dao.search(filter);
                if (assetTypes.Count > 0)
                {
                    hdfId.Value = typeId.ToString();
                    tbxName.Text = assetTypes[0].Name;
                    tbxParent.Text = assetTypes[0].Parent.Name;
                    txaDescription.Text = assetTypes[0].Description;
                }
            }
        }
    }
}
